package com.cloud.minioService.controller;

import com.cloud.minioService.service.EmailService;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhozixiong
 * @date 2023/03/20
 */
@RestController
@RequestMapping("/email")
public class EmailController {

    @Autowired
    private EmailService emailService;

    @Autowired
    private DefaultKaptcha defaultKaptcha;

    @GetMapping("/code/{qqEmail}")
    public String code(@PathVariable String qqEmail) {
        //生成验证码
        String code = defaultKaptcha.createText();
        //发送邮件
        emailService.sendSimpleMail(qqEmail, code);
        return code;
    }
}
